/************************ (C) COPYRIGHT Megahuntmicro *************************
 * File Name            : AT25040B_driver.h
 * Author               : Megahuntmicro
 * Version              : V1.0.0
 * Date                 : 01/23/2015
 * Description          : AT25040B driver.
 *****************************************************************************/
 
 
#ifndef __AT25040B_DRIVER_H__
#define __AT25040B_DRIVER_H__
 
 
#ifdef __cplusplus
extern "C" {
#endif
	
/* Include ------------------------------------------------------------------*/
#include "mhscpu.h"	

#define CS_PORT     GPIOB
#define CS_PIN      GPIO_Pin_10    
    
#define WREN        0x06    /* Set write enable latch */
#define WRID        0x04    /* Reset write enable latch */
#define RDSR        0x05    /* Read status register */
#define WRSR        0x01    /* Write status register */
#define READ        0x03    /* Read data from memory array(0b0000 A011,"A" 
                             * represents MSB address bit A8 for the AT25040B) 
                             */
#define WRITE       0x02    /* Write data to memory array(0b0000 A010,"A" 
                             * represents MSB address bit A8 for the AT25040B) 
                             */
/* Exported types -----------------------------------------------------------*/
/* Exported constants -------------------------------------------------------*/	
/* Exported macro -----------------------------------------------------------*/	
/* Exported functions -------------------------------------------------------*/	
/* Exported variables -------------------------------------------------------*/	
uint8_t AT25040B_Write_byte(SPI_TypeDef *SPIx, uint16_t start_addr, uint8_t write_byte);    
uint8_t AT25040B_Write_Mulitbytes(SPI_TypeDef *SPIx, 
                                  uint16_t start_addr, 
                                  uint8_t *Buf,
                                  uint32_t write_data_num);
uint8_t AT25040B_read_byte(SPI_TypeDef *SPIx, uint16_t start_addr,uint8_t *read_data_value);	
uint8_t AT25040B_Read_Mulitbytes(SPI_TypeDef *SPIx, 
                                 uint16_t start_addr, 
                                 uint8_t *Buf,
                                 uint32_t read_data_num);	 
#ifdef __cplusplus
}
#endif	 

#endif	/* __AT25040B_DRIVER_H__ */
/************************ (C) COPYRIGHT 2014 Megahuntmicro ****END OF FILE****/
